package com.sp.pay.repository.company;

import com.sp.pay.dto.QueryDto;
import com.sp.pay.dto.company.CompanyDto;
import com.sp.pay.dto.company.CompanyParameterDto;
import com.sp.pay.mapper.company.CompanyMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;

import java.util.List;

@Repository
public class CompanyRepositoryImp implements CompanyRepository{

    @Autowired
    private CompanyMapper companyMapper;

    public void save(CompanyDto dto) {
        if(dto!=null&&dto.getId()>0){
            companyMapper.update(dto);
        }else{
            companyMapper.insert(dto);
        }
    }

    public void delete(int id) {
        companyMapper.delete(id);
    }

    public CompanyDto findById(int id) {
        return companyMapper.findById(id);
    }

    public CompanyDto queryS_Company(String company_num){
        return companyMapper.queryS_Company(company_num);
    }

    public CompanyDto queryP_Company(String company_num){
        return companyMapper.queryP_Company(company_num);
    }

    public List<CompanyDto> query(QueryDto queryDto) {
        return companyMapper.query(queryDto);
    }

    public CompanyParameterDto queryS_Para(String company_num){
        return companyMapper.queryS_Para(company_num);
    }

    public CompanyParameterDto queryP_Para(String company_num){
        {
            return companyMapper.queryP_Para(company_num);
        }
    }

    public void savePara(CompanyParameterDto companyParameterDto){
        if(companyParameterDto!=null&&companyParameterDto.getId()>0){
            companyMapper.updatePara(companyParameterDto);
        }else{
            companyMapper.insertPara(companyParameterDto);
        }
    }
}
